package service.impl;

import dao.RaceDao;
import dao.impl.RaceDaoImpl;
import model.Race;
import service.RaceService;

import java.util.List;

/**
 * @Author: 燕子豪
 * @Date: 2022/12/17 15:26
 */
public class RaceServiceImpl implements RaceService {
    RaceDao raceDao = new RaceDaoImpl();

    @Override
    public Boolean update(Race race) {
        int result = raceDao.update(race);
        return result == 1;
    }

    @Override
    public Boolean insert(Race race) {
        int result = raceDao.insert(race);
        return result == 1;
    }

    @Override
    public List<Race> getAllRaces(int pageSize, int pageIndex) {
        return raceDao.getAllRaces(pageSize, pageIndex);
    }

    @Override
    public List<Race> getRacesByUser(int uid, int pageSize, int pageIndex) {
        return raceDao.getRacesByUser(uid, pageSize, pageIndex);
    }

    @Override
    public Boolean delete(int rid) {
        int result = raceDao.delete(rid);
        return result == 1;
    }

    @Override
    public List<Race> findByPartName(String partName, int pageIndex, int pageSize) {
        return raceDao.findByPartName(partName, pageIndex, pageSize);
    }

    @Override
    public int countByName(String partName) {
        return raceDao.countByName(partName);
    }

    @Override
    public int pageCount() {
        return raceDao.pageCount();
    }

    @Override
    public int countByUser(int uid) {
        return raceDao.countByUser(uid);
    }

    @Override
    public Race getRaceById(int rid) {
        return raceDao.getRaceById(rid);
    }
}
